/*
 * Copyright (c) 2014 - 2016. Company.Domain Co.Ltd. All rights reserved.
 */

package cn.com.dhc.danlu.activity.category;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
import android.renderscript.Int2;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import cn.com.dhc.danlu.R;
import cn.com.dhc.danlu.activity.BaseActivity;
import cn.com.dhc.danlu.util.ACache;
import cn.com.dhc.danlu.util.CommonConst;
import cn.com.dhc.danlu.util.CommonUtils;
import cn.com.dhc.danlu.util.CommonUtils.CachingArrayList;
import cn.com.dhc.danlu.util.SerializeCache;
import cn.com.dhc.danlu.widget.RightCharacterListView;
import cn.com.dhc.danlu.widget.RightCharacterListView.OnTouchingLetterChangedListener;
import cn.com.dhc.danlu.widget.adapter.BrandNameListAdapter;
import cn.com.hd.mall.web.common.Tuple;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.BeerCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.DailyUsedCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.DrinksCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.ElectricCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.ForeignWineCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.GrainCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.HardwareCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.NonStapleCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.OthersCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.SpiritCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.TeaCategoryItem;
import cn.com.hd.mall.web.webservices.entity.response.merch.MerchCategoryListResponse.WineCategoryItem;

import static cn.com.dhc.danlu.dlware.global.DanluApplication.agent;

/**
 * author: MuWei
 * author: 刘立琦(<a href="mailto:liuliqi@danlu.com">liuliqi@danlu.com</a>)<br/>
 * version: 1.0.0<br/>
 * since: 2015-02-12 15:04<br/>
 *
 * <p>
 * 品牌筛选画面
 * </p>
 */
public class CategoryTeaBrandFilterActivity extends BaseActivity {
    /**
     * 记录茶类点击的位置
     */
    private static int TEA_SEED_POSITION = 0;
    /**
     * 记录茶类是否改变
     */
    private static boolean TEA_SEED_CHANGE = false;
    private LinearLayout llytOk;
    /**
     * 取消按钮
     */
    private LinearLayout llytCancel;
    /**
     * ListView数据Adapter
     */
    private BrandNameListAdapter listAdapter;
    /**
     * 品牌、国家、香型等等的展示 ListView
     */
    private ListView lstBrandName;
    /**
     * 品牌名称所有首字母List
     */
    private ArrayList<BrandName> allCharacterList = new ArrayList<>();
    /**
     * 品牌名称第一个首字母List
     */
    private ArrayList<String> singleCharacterList = new ArrayList<>();
    /**
     * 品牌数据
     */
    private List<String> brandNameList = new ArrayList<>();
    /**
     * 茶类数据
     */
    private List<String> teaSeedNameList = new ArrayList<>();
    /**
     * 茶种数据
     */
    private List<String> teaSortNameList = new ArrayList<>();
    /**
     * 香型数据  名称
     */
    private List<String> ordorNameList = new ArrayList<>();
    /**
     * 葡萄酒数据
     */
    private List<String> redWinePlaceNameList = new ArrayList<>();
    /**
     * 洋酒分类数据   分类名
     */
    private List<String> foreignClassifyNameList = new ArrayList<>();
    /**
     * 洋酒国家数据
     */
    private List<String> foreignCountryNameList = new ArrayList<>();
    /**
     * 啤酒国家数据  国家名
     */
    private List<String> beerCountryNameList = new ArrayList<>();
    /**
     * 啤酒分类数据   分类名
     */
    private List<String> beerClassifyNameList = new ArrayList<>();
    /**
     * 右侧英文导航栏
     */
    private RightCharacterListView rclstNavigation;
    /**
     * 事务处理Handler
     */
    private Handler handler;
    /**
     * 浮动文本
     */
    private TextView txtOverlay;
    /**
     * 浮动文字消失线程
     */
    private DisapearThread disapearThread;
    /**
     * 任务类
     */
    //    private DanluTaskProxy danluTaskProxy;
    /**
     * 茶类
     */
    private String teaSeed = null;
    /**
     * 存放品牌id的List   品牌码
     */
    private ArrayList<String> brandCodeList = new ArrayList<>();
    /**
     * 茶类的List  茶类码
     */
    private ArrayList<String> teaSeedList = new ArrayList<>();
    /**
     * 茶种的List  茶种码
     */
    private ArrayList<String> teaSortList = new ArrayList<>();
    /**
     * 香型的list  香型码
     */
    private ArrayList<String> ordorList = new ArrayList<>();
    /**
     * 葡萄酒的list   产地码
     */
    private ArrayList<String> redWinePlaceList = new ArrayList<>();
    /**
     * 洋酒的分类list   分类码
     */
    private ArrayList<String> foreignClassifyList = new ArrayList<>();
    /**
     * 洋酒的国家list   国家码
     */
    private ArrayList<String> foreignCountryList = new ArrayList<>();
    /**
     * 啤酒的国家list   国家码
     */
    private ArrayList<String> beerCountryList = new ArrayList<>();
    /**
     * 啤酒的分类list   分类码
     */
    private ArrayList<String> beerClassifyList = new ArrayList<>();
    /**
     * 返回意图对象
     */
    private Intent brandData;
    /**
     * 茶类列表
     */
    private ArrayList<TeaCategoryItem> teaSeedItem;
    /**
     * 茶种列表
     */
    private ArrayList<TeaCategoryItem> teaSortItem;
    /**
     * 茶品牌列表
     */
    private ArrayList<TeaCategoryItem> teaBrandItem;
    /**
     * 白酒列表
     */
    private SpiritCategoryItem wineItem;
    /**
     * 香型列表
     */
    private SpiritCategoryItem ordorItem;
    /**
     * 葡萄酒品牌列表
     */
    private WineCategoryItem redWineItem;
    /**
     * 葡萄酒产地列表
     */
    private WineCategoryItem redWinePlaceItem;
    /**
     * 洋酒列表
     */
    private ForeignWineCategoryItem foreignItem;
    /**
     * 洋酒颜色列表
     */
    private ForeignWineCategoryItem foreignClassifyItem;
    /**
     * 洋酒国家 列表
     */
    private ForeignWineCategoryItem foreignCountryItem;
    /**
     * 啤酒列表
     */
    private BeerCategoryItem beerItem;
    /**
     * 啤酒分类列表
     */
    private BeerCategoryItem beerClassifyItem;
    /**
     * 饮料品牌
     */
    private DrinksCategoryItem mDrinksBrandItem;
    /**
     * 粮油品牌
     */
    private GrainCategoryItem mGrainBrandItem;
    /**
     * 副食品牌
     */
    private NonStapleCategoryItem mNonStapleBrandItem;
    /**
     * 日化用品品牌
     */
    private DailyUsedCategoryItem mDailyUsedBrandItem;
    /**
     * 五金品牌
     */
    private HardwareCategoryItem mHardwareBrandItem;
    /**
     * 家电品牌
     */
    private ElectricCategoryItem mElectricBrandItem;
    /**
     * 啤酒国家列表
     */
    private BeerCategoryItem beerCountryItem;
    /**
     * 标题
     */
    private TextView title;

    /**
     * 品牌名
     */
    private String brandName = null;

    /**
     * 是否点击了
     */
    private boolean isClick = false;

    /**
     * 茶类code
     */
    private String teaSeedCode;
    /**
     * 茶种code
     */
    private String teaSortCode;
    /**
     * 品牌code
     */
    private String goodsBrandCode;
    /**
     * 葡萄酒国家code
     */
    private String redWineCountryCode;
    /**
     * 白酒香型code
     */
    private String ordorCode;
    /**
     * 洋酒国家code
     */
    private String fCountryCode;
    /**
     * 洋酒分类code
     */
    private String fClassifyCode;
    /**
     * 啤酒分类code
     */
    private String beerClassifyCode;
    /**
     * 啤酒国家code
     */
    private String beerCountryCode;
    /**
     * 点击的item数据
     */
    private BrandName clickItem;
    /**
     * 缓存数据
     */
    private ACache aCache;
    /**
     * 品牌、酒品的分类、产地等列表点击监听。
     */
    private OnItemClickListener lstBrandNameClickListener = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            int selectedPosition = position - lstBrandName.getHeaderViewsCount();
            if (selectedPosition < 0) {
                return;
            }
            listAdapter.setSelectedIndex(position);
            listAdapter.notifyDataSetChanged();
            isClick = true;
            // 得到点击的茶类Item
            if (teaSeedNameList.size() > 0 && teaSeedList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    teaSeedCode = teaSeedList.get(teaSeedNameList
                            .indexOf(clickItem.getName()) - 1);    //茶类列表第一项为“全部”
                    brandData.putExtra("position", position);
                    brandData.putExtra("TEACODE", teaSeedCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.TEA_SEED, clickItem.getName());
                } else {
                    String teaSeedCode = null;
                    brandData.putExtra("TEABRANDITEM", teaSeedCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.TEA_SEED, clickItem.getName());  //传入全部
                }
            }
            // 得到点击的茶种Item
            if (teaSortNameList.size() > 0 && teaSortList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    teaSortCode = teaSortList.get(teaSortNameList
                            .indexOf(clickItem.getName()) - 1);
                    brandData.putExtra("TEASORT", teaSortCode);   //茶种码
                    // 将点击的选项的茶种名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.TEA_SORT, clickItem.getName());
                } else {
                    String teaSortCode = null;
                    brandData.putExtra("TEABRANDITEM", teaSortCode);    //茶种码
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.TEA_SORT, clickItem.getName());
                }
            }
            // 得到点击的香型item

            if (ordorNameList.size() > 0 && ordorList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    ordorCode = ordorList.get(ordorNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.ORDOR_CONSTANT, ordorCode);   //香型码
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.ORDOR_TYPE, clickItem.getName());
                } else {
                    String ordorCode = null;
                    brandData.putExtra("TEABRANDITEM", ordorCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.ORDOR_TYPE, clickItem.getName());
                }
            }
            // 得到点击的洋酒分类item
            if (foreignClassifyNameList.size() > 0 && foreignClassifyList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    fClassifyCode = foreignClassifyList.get(foreignClassifyNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY_CONSTANT, fClassifyCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY, clickItem.getName());
                } else {
                    String fClassifyCode = null;
                    brandData.putExtra("TEABRANDITEM", fClassifyCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY, clickItem.getName());
                }
            } // 得到点击的洋酒国家item
            if (foreignCountryNameList.size() > 0 && foreignCountryList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    fCountryCode = foreignCountryList.get(foreignCountryNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY_CONSTANT, fCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY, clickItem.getName());
                } else {
                    String fCountryCode = null;
                    brandData.putExtra("TEABRANDITEM", fCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY, clickItem.getName());
                }
            }
            // 得到点击的啤酒分类item
            if (beerClassifyNameList.size() > 0 && beerClassifyList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    beerClassifyCode = beerClassifyList.get(beerClassifyNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY_CONSTANT, beerClassifyCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY, clickItem.getName());
                } else {
                    String beerClassifyCode = null;
                    brandData.putExtra("TEABRANDITEM", beerClassifyCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY, clickItem.getName());
                }
            } // 得到点击的啤酒国家item
            if (beerCountryNameList.size() > 0 && beerCountryList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    beerCountryCode = beerCountryList.get(beerCountryNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY_CONSTANT, beerCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY, clickItem.getName());
                } else {
                    String beerCountryCode = null;
                    brandData.putExtra("TEABRANDITEM", beerCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY, clickItem.getName());
                }
            }

            // 得到点击的葡萄酒产地item
            if (redWinePlaceNameList.size() > 0 && redWinePlaceList.size() > 0) {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    redWineCountryCode = redWinePlaceList.get(redWinePlaceNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra(CommonConst.IntentKey.RED_WINE_CONSTANT, redWineCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.RED_WINE_PLACE, clickItem.getName());
                } else {
                    String redWineCountryCode = null;
                    brandData.putExtra("TEABRANDITEM", redWineCountryCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.RED_WINE_PLACE, clickItem.getName());
                }
            }
            //品牌
            if (brandNameList.size() > 0 && brandCodeList.size() > 0) {
                // 得到点击的品牌Item
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                // 创建一个意图对象]
                if (!clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    goodsBrandCode = brandCodeList.get(brandNameList.indexOf(clickItem.getName()) - 1);
                    brandData.putExtra("TEABRANDITEM", goodsBrandCode);   //存入品牌码
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, clickItem.getName());
                } else {
                    String teaBrandCode = null;
                    brandData.putExtra("TEABRANDITEM", teaBrandCode);
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, clickItem.getName());
                }
            } else {
                clickItem = (BrandName) arg0.getAdapter().getItem(position);
                String teaBrandCode = null;
                brandData.putExtra("TEABRANDITEM", teaBrandCode);
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, clickItem.getName());
            }
            if (teaSeed != null && teaSeed.equals(CommonConst.IntentKey.TEA_SEED)) {
                // 茶类点击位置
                TEA_SEED_POSITION = position;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //        getDelegate().setContentView(R.layout.layout_category_brand_filter, R.layout_category_brand_filter.class);
        setContentView(R.layout.layout_category_brand_filter);

        initViews();
        setViews();
        setListener();
    }

    @SuppressLint("InflateParams")
    private void initViews() {
        txtOverlay = (TextView) LayoutInflater.from(this).inflate(R.layout.view_popup_char, null);
        llytOk = (LinearLayout) findViewById(R.id.llytOK);
        llytCancel = (LinearLayout) findViewById(R.id.llytCancel);
        lstBrandName = (ListView) findViewById(R.id.lstBrandName);
        rclstNavigation = (RightCharacterListView) findViewById(R.id.rclstNavigation);
        title = (TextView) findViewById(R.id.title);
    }

    @Override
    protected String getActivityTitle() {
        return null;
    }

    /**
     * 画面初始化
     */
    @SuppressLint("RtlHardcoded")
    private void setViews() {
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        // 获取对话框当前的参值
        LayoutParams p = getWindow().getAttributes();
        // 高度设置为屏幕高度 - 底部导航栏height
        p.height = (int) (dm.heightPixels - dm.density * 53);
        // 宽度设置为屏幕的0.8
        p.width = (int) (dm.widthPixels * 0.8);
        // 设置生效
        getWindow().setAttributes(p);
        // 设置靠右对齐
        getWindow().setGravity(Gravity.RIGHT | Gravity.TOP);

        // 获取筛选品牌名，品牌点击监听处传入
        brandName = getIntent().getStringExtra(CommonConst.IntentKey.BRAND_NAME);
        // 列表数据点击事件监听
        lstBrandName.setOnItemClickListener(lstBrandNameClickListener);
        brandData = new Intent();
        // 将点击的选项的品牌名加入到意图对象中
        brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
        // 将点击的选项的品牌码加入到意图对象中
        brandData.putExtra("brand_code", "null");
        getData(getIntent().getExtras()); // 获取数据
    }

    /**
     * 获取数据
     */
    private void getData(Bundle bundle) {
        aCache = ACache.get(getApplicationContext());
        // 得到茶类
        teaSeed = bundle.getString(CommonConst.IntentKey.TEA_SEED);
        // 得到茶种
        String teaSort = bundle.getString(CommonConst.IntentKey.TEA_SORT);
        // 得到香型
        String ordorType = bundle.getString(CommonConst.IntentKey.ORDOR_TYPE);
        // 得到葡萄酒
        String redWine = bundle.getString(CommonConst.IntentKey.RED_WINE_PLACE);
        // 得到洋酒分类
        String foreingClassify = bundle.getString(CommonConst.IntentKey.FOREIGN_CLASSIFY);
        // 得到洋酒国家
        String foreingCountry = bundle.getString(CommonConst.IntentKey.FOREIGN_COUNTRY);
        // 得到啤酒分类
        String beerClassify = bundle.getString(CommonConst.IntentKey.BEER_CLASSIFY);
        // 得到啤酒国家
        String beerCountry = bundle.getString(CommonConst.IntentKey.BEER_COUNTRY);
        // 获取茶类数据
        teaSeedItem = (ArrayList<TeaCategoryItem>) bundle.getSerializable(CommonConst.IntentKey.TEA_SEED_CONSTANT);
        // 获取茶种数据
        teaSortItem = (ArrayList<TeaCategoryItem>) bundle.getSerializable(CommonConst.IntentKey.TEA_SORT_CONSTANT);
        // 获取茶品牌数据
        teaBrandItem = (ArrayList<TeaCategoryItem>) bundle.getSerializable(CommonConst.IntentKey.TEA_BRAND_CONSTANT);
        // 获取酒品牌数据
        wineItem = (SpiritCategoryItem) bundle.getSerializable(CommonConst.IntentKey.WINE_WORD);
        // 获取香型数据
        ordorItem = (SpiritCategoryItem) bundle.getSerializable(CommonConst.IntentKey.ORDOR_CONSTANT);
        // 获取葡萄酒品牌数据
        redWineItem = (WineCategoryItem) bundle.getSerializable(CommonConst.IntentKey.RED_WINE_WORD);
        // 获取饮料品牌数据
        mDrinksBrandItem = (DrinksCategoryItem) bundle.getSerializable("饮料");
        // 获取粮油品牌数据
        mGrainBrandItem = (GrainCategoryItem) bundle.getSerializable("粮油");
        // 获取副食品牌数据
        mNonStapleBrandItem = (NonStapleCategoryItem) bundle.getSerializable("副食");
        // 获日化用品食品牌数据
        mDailyUsedBrandItem = (DailyUsedCategoryItem) bundle.getSerializable("日化用品");
        // 获取五金品牌数据
        mHardwareBrandItem = (HardwareCategoryItem) bundle.getSerializable("五金");
        // 获取家电品牌数据
        mElectricBrandItem = (ElectricCategoryItem) bundle.getSerializable("家电");
        // 获取其他饮品品牌数据
        //        othersItem = (OthersCategoryItem) bundle.getSerializable ("其它");  //不走此页面了
        // 获取葡萄酒产地数据
        redWinePlaceItem = (WineCategoryItem) bundle.getSerializable(CommonConst.IntentKey.RED_WINE_CONSTANT);
        // 获取洋酒品牌数据
        foreignItem = (ForeignWineCategoryItem) bundle.getSerializable(CommonConst.IntentKey.FOREIGN_WINE_WORD);
        // 获取啤酒品牌数据
        beerItem = (BeerCategoryItem) bundle.getSerializable(CommonConst.IntentKey.BEER_WORD);
        // 获取洋酒分类数据
        foreignClassifyItem = (ForeignWineCategoryItem) bundle.getSerializable(CommonConst.IntentKey.FOREIGN_CLASSIFY_CONSTANT);
        // 获取洋酒国家数据
        foreignCountryItem = (ForeignWineCategoryItem) bundle.getSerializable(CommonConst.IntentKey.FOREIGN_COUNTRY_CONSTANT);
        // 获取啤酒国家数据
        beerCountryItem = (BeerCategoryItem) bundle.getSerializable(CommonConst.IntentKey.BEER_COUNTRY_CONSTANT);
        // 获取啤酒类别数据
        beerClassifyItem = (BeerCategoryItem) bundle.getSerializable(CommonConst.IntentKey.BEER_CLASSIFY_CONSTANT);
        // 改变标题文字
        if (teaSeed != null && teaSeed.equals(CommonConst.IntentKey.TEA_SEED)) {  // 茶类
            // 将点击的position加入到意图对象中
            brandData.putExtra("TEACODE", "null");
            brandData.putExtra(CommonConst.IntentKey.TEA_SEED, "null");
            setAdapterTitle(teaSeed, false, View.GONE);
            updateTeaSeedView(teaSeedItem);
            // 获取上次点击的行数
            Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.CATEGORY);
            List<Tuple<String, String>> tuples = new ArrayList<>();
            for (int i = 0; i < teaSeedItem.size(); i++) {
                tuples.add(teaSeedItem.get(i).getCategoryTuple());
            }
            Tuple<Integer, Integer> index = CommonUtils.getAcacheIndex(tuple, tuples);
            if (index != null) {
                listAdapter.setSelectedIndex(index.getSecondValue() + 1);

            } else {
                listAdapter.setSelectedIndex(0);
            }
            listAdapter.notifyDataSetChanged();
        } else if (teaSort != null && teaSort.equals(CommonConst.IntentKey.TEA_SORT)) { // 茶种
            brandData.putExtra("TEASORT", "null");
            brandData.putExtra(CommonConst.IntentKey.TEA_SORT, "null");
            // 设置适配器设置标题
            setAdapterTitle(teaSort, false, View.GONE);
            updateTeaSortView(teaSortItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(teaSortItem.get(TEA_SEED_POSITION - 1).getPropertyTupleList());
                }
            });
            // 香型
        } else if (ordorType != null && ordorType.equals(CommonConst.IntentKey.ORDOR_TYPE)) {
            brandData.putExtra(CommonConst.IntentKey.ORDOR_TYPE, "null");
            // 设置适配器设置标题
            setAdapterTitle(ordorType, false, View.GONE);
            updateOrdorTypeView(ordorItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(ordorItem.getOdorTupleList());
                }
            });
            // 葡萄酒产地
        } else if (redWine != null && redWine.equals(CommonConst.IntentKey.RED_WINE_PLACE)) {
            brandData.putExtra(CommonConst.IntentKey.RED_WINE_PLACE, "null");
            title.setText(redWine);
            // 设置适配器设置标题
            setAdapterTitle(redWine, false, View.GONE);
            updateRedWineView(redWinePlaceItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(redWinePlaceItem.getProductionTupleList());
                }
            });
        } else if (foreingClassify != null && foreingClassify.equals(CommonConst.IntentKey.FOREIGN_CLASSIFY)) { // 洋酒分类
            brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY, "null");
            // 设置适配器设置标题
            setAdapterTitle(foreingClassify, false, View.GONE);
            updateForeignWineColorView(foreignClassifyItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(foreignClassifyItem.getClassifyTupleList());
                }
            });
        } else if (foreingCountry != null && foreingCountry.equals(CommonConst.IntentKey.FOREIGN_COUNTRY)) { // 洋酒国家
            brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY, "null");
            // 设置适配器设置标题
            setAdapterTitle(foreingCountry, false, View.GONE);
            updateForeignWineCountryView(foreignCountryItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(foreignCountryItem.getCountryTupleList());
                }
            });
        } else if (beerCountry != null && beerCountry.equals(CommonConst.IntentKey.BEER_COUNTRY)) { // 啤酒国家
            brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY, "null");
            // 设置适配器设置标题
            setAdapterTitle(beerCountry, false, View.GONE);
            updateBeerCountryView(beerCountryItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(beerCountryItem.getCountryTupleList());
                }
            });
        } else if (beerClassify != null && beerClassify.equals(CommonConst.IntentKey.BEER_CLASSIFY)) { // 啤酒分类
            brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY, "null");
            // 设置适配器设置标题
            setAdapterTitle(beerClassify, false, View.GONE);
            updateBeerClassifyView(beerClassifyItem);
            // 获取上次点击item
            checkTextViewIndex(new ArrayList<List<Tuple<String, String>>>() {
                {
                    add(beerClassifyItem.getClassifyTupleList());
                }
            });
        } else {
            if (!TextUtils.isEmpty(brandName) && brandName.equals(CommonConst.IntentKey.TEA_WORD)) { // 茶品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandListView(teaBrandItem);
            } else if (!TextUtils.isEmpty(brandName) && brandName.equals(CommonConst.IntentKey.WINE_WORD)) { // 白酒品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandWineListView(wineItem);
            } else if (brandName != null && brandName.equals(CommonConst.IntentKey.RED_WINE_WORD)) { // 葡萄酒品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandRedWineListView(redWineItem);
            } else if (brandName != null && brandName.equals(CommonConst.IntentKey.FOREIGN_WINE_WORD)) { // 洋酒品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandForeignWineListView(foreignItem);
            } else if (brandName != null && brandName.equals(CommonConst.IntentKey.BEER_WORD)) { // 啤酒品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBeerListView(beerItem);
            } else if (brandName != null
                    && brandName.equals("饮料")) {     // 饮料品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandDrinksListView(mDrinksBrandItem);   //更新饮料品牌列表
            } else if (brandName != null
                    && brandName.equals("粮油")) {     // 粮油品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandGrainListView(mGrainBrandItem);  //更新粮油品牌列表
            } else if (brandName != null
                    && brandName.equals("副食")) { // 副食品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandNonStapleListView(mNonStapleBrandItem);
            } else if (brandName != null
                    && brandName.equals("日化用品")) {      // 日化用品品牌
                brandData.putExtra("TEABRANDITEM", "null");   // 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandDailyUsedListView(mDailyUsedBrandItem);
            } else if (brandName != null
                    && brandName.equals("五金")) {     //五金品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandHardwareListView(mHardwareBrandItem);
            } else if (brandName != null
                    && brandName.equals("家电")) {       //家电品牌
                brandData.putExtra("TEABRANDITEM", "null");// 品牌code
                brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, "null");
                // 设置适配器设置标题
                setAdapterTitle(CommonConst.IntentKey.BRAND_WORD, true, View.VISIBLE);
                updateBrandElectricListView(mElectricBrandItem);
            }
        }
    }

    /**
     * 什么也没点击获取缓存数据
     */
    @SuppressWarnings("unchecked")
    private void noClick() {
        if (!isClick) {
            if (teaSeedItem != null) { // 茶类
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.CATEGORY);
                if (tuple != null) {
                    brandData.putExtra("TEACODE", tuple.getFirstValue());
                    // 将上次点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.TEA_SEED, tuple.getSecondValue());
                }
                int selectIndex = listAdapter.getSelectIndex();
                BrandName item = (BrandName) listAdapter.getItem(selectIndex);
                if (null != item) {
                    brandData.putExtra(CommonConst.IntentKey.TEA_SEED, item.getName());  // 返回上次选中茶类名
                }
            } else if (teaSortItem != null) {
                //茶种
                int selectIndex = listAdapter.getSelectIndex();
                BrandName item = (BrandName) listAdapter.getItem(selectIndex);
                if (null != item) {
                    brandData.putExtra(CommonConst.IntentKey.TEA_SORT, item.getName());
                }
            } else if (wineItem != null) { // 白酒品牌
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
                if (tuple != null) {
                    brandData.putExtra("TEABRANDITEM", tuple.getFirstValue());  //品牌码
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, tuple.getSecondValue()); //品牌名
                }
            } else if (mDrinksBrandItem != null || mGrainBrandItem != null || mNonStapleBrandItem != null
                    || mDailyUsedBrandItem != null || mHardwareBrandItem != null || mElectricBrandItem != null) { // 饮料|粮油|副食|日化用品|五金|家电品牌
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
                if (tuple != null) {
                    brandData.putExtra("TEABRANDITEM", tuple.getFirstValue());
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, tuple.getSecondValue());
                }
            } else if (redWineItem != null) { // 葡萄酒品牌
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
                if (tuple != null) {
                    brandData.putExtra("TEABRANDITEM", tuple.getFirstValue());
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, tuple.getSecondValue());
                }
            } else if (foreignItem != null) { // 洋酒品牌
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
                if (tuple != null) {
                    brandData.putExtra("TEABRANDITEM", tuple.getFirstValue());
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, tuple.getSecondValue());
                }
            } else if (beerItem != null) { // 啤酒品牌
                Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
                if (tuple != null) {
                    brandData.putExtra("TEABRANDITEM", tuple.getFirstValue());
                    // 将点击的选项的品牌名加入到意图对象中
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, tuple.getSecondValue());
                }
            } else if (ordorItem != null) { // 香型
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    // code
                    brandData.putExtra(CommonConst.IntentKey.ORDOR_CONSTANT, tuple.get(0).getSecondValue());
                    // name
                    brandData.putExtra(CommonConst.IntentKey.ORDOR_TYPE, tuple.get(0).getThirdValue());
                }
            } else if (redWinePlaceItem != null) { // 产地
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    brandData.putExtra(CommonConst.IntentKey.RED_WINE_CONSTANT, tuple.get(0).getSecondValue());   //产地码
                    brandData.putExtra(CommonConst.IntentKey.RED_WINE_PLACE, tuple.get(0).getThirdValue());   //产地名
                }
            } else if (foreignClassifyItem != null) { // 洋酒类型
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    for (int i = 0; i < tuple.size(); i++) {
                        if (tuple.get(i).getFirstValue().equals(CommonConst.IntentKey.FOREIGN_CLASSIFY)) {
                            brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY_CONSTANT, tuple.get(i).getSecondValue());
                            brandData.putExtra(CommonConst.IntentKey.FOREIGN_CLASSIFY, tuple.get(i).getThirdValue());
                        }
                    }

                }
            } else if (foreignCountryItem != null) { // 洋酒国家
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    for (int i = 0; i < tuple.size(); i++) {
                        if (tuple.get(i).getFirstValue().equals(CommonConst.IntentKey.FOREIGN_COUNTRY)) {
                            brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY_CONSTANT, tuple.get(i).getSecondValue());   //类型码
                            brandData.putExtra(CommonConst.IntentKey.FOREIGN_COUNTRY, tuple.get(i).getThirdValue());   //类型名
                        }
                    }
                }
            } else if (beerClassifyItem != null) { // 啤酒类型
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    for (int i = 0; i < tuple.size(); i++) {
                        if (tuple.get(i).getFirstValue().equals(CommonConst.IntentKey.BEER_CLASSIFY)) {
                            brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY_CONSTANT, tuple.get(i).getSecondValue());
                            // 将点击的选项的品牌名加入到意图对象中
                            brandData.putExtra(CommonConst.IntentKey.BEER_CLASSIFY, tuple.get(i).getThirdValue());
                        }
                    }

                }
            } else if (beerCountryItem != null) { // 啤酒国家
                CachingArrayList tuple = (CachingArrayList) ACache.get(this).getAsObject(CommonConst.ACacheComstants.PROPERTY);
                if (tuple != null) {
                    for (int i = 0; i < tuple.size(); i++) {
                        if (tuple.get(i).getFirstValue().equals(CommonConst.IntentKey.BEER_COUNTRY)) {
                            brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY_CONSTANT, tuple.get(i).getSecondValue()); // 啤酒国家码
                            // 将点击的选项的品牌名加入到意图对象中
                            brandData.putExtra(CommonConst.IntentKey.BEER_COUNTRY, tuple.get(i).getThirdValue()); // 啤酒国家名
                        }
                    }

                }
            }
            //why
            if (null != listAdapter) {
                int selectIndex = listAdapter.getSelectIndex();
                if (selectIndex != -1) {
                    clickItem = (BrandName) listAdapter.getItem(selectIndex);
                    brandData.putExtra(CommonConst.IntentKey.BRAND_NAME, clickItem.getName());
                }
            }
        } else {
            // 点击后保存缓存数据
            if (teaBrandItem != null) { // 茶品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放到缓存中
                    CategoryTeaBrandFilterActivity.TEA_SEED_CHANGE = false;
                }
            } else if (wineItem != null) { // 白酒品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (mDrinksBrandItem != null) { // 饮料品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (mGrainBrandItem != null) { // 粮油品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (mNonStapleBrandItem != null) { // 副食品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (mDailyUsedBrandItem != null || mHardwareBrandItem != null || mElectricBrandItem != null) { // 日化用品，五金，家电品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (redWineItem != null) { // 葡萄酒品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (foreignItem != null) { // 洋酒品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (beerItem != null) { // 啤酒品牌
                if (clickItem.getName().equals(getResources().getText(R.string.category_brand_all))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                } else {
                    CommonUtils.cachingBrandId(getApplicationContext(), goodsBrandCode, clickItem.getName()); // 品牌放入缓存
                }
            } else if (ordorItem != null) { // 香型
                if (clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                } else {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                    CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.ORDOR_TYPE, ordorCode, clickItem.getName());
                }
            } else if (redWinePlaceItem != null) { // 产地
                if (clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                } else {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                    CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.RED_WINE_PLACE, redWineCountryCode, clickItem.getName());
                }
            } else if (foreignClassifyItem != null) { // 洋酒类型
                CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.FOREIGN_CLASSIFY, fClassifyCode, clickItem.getName());
            } else if (foreignCountryItem != null) { // 洋酒国家
                CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.FOREIGN_COUNTRY, fCountryCode, clickItem.getName());
            } else if (beerClassifyItem != null) { // 啤酒类型
                CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.BEER_CLASSIFY, beerClassifyCode, clickItem.getName());
            } else if (beerCountryItem != null) { // 啤酒国家
                CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.BEER_COUNTRY, beerCountryCode, clickItem.getName());
            } else if (teaSeedItem != null) { // 茶类
                if (clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.CATEGORY);
                    aCache.remove(CommonConst.ACacheComstants.BRAND);
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                } else {
                    CommonUtils.cachingCategoryCode(getApplicationContext(), teaSeedCode, clickItem.getName());
                    CategoryTeaBrandFilterActivity.TEA_SEED_CHANGE = true;
                }
            } else if (teaSortItem != null) { // 茶种
                if (clickItem.getName().equals(getResources().getText(R.string.category_all_label))) {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                } else {
                    // 清空缓存
                    aCache.remove(CommonConst.ACacheComstants.PROPERTY);
                    CommonUtils.cachingPropertyCode(getApplicationContext(), CommonConst.IntentKey.TEA_SORT, teaSortCode, clickItem.getName());
                }
            }
        }
    }

    /**
     * 通过任务的数据来更新茶类UI
     */
    private void updateTeaSeedView(ArrayList<TeaCategoryItem> list) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < list.size(); i++) {
            model.add(list.get(i).getCategoryTuple().getSecondValue());   //茶类名
            teaSeedList.add(list.get(i).getCategoryTuple().getFirstValue());   //茶类码
        }
        teaSeedNameList.clear();
        teaSeedNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();

        // 获取姓名的拼音缩写
        for (int i = 0; i < teaSeedNameList.size(); i++) {
            String dataItem = teaSeedNameList.get(i);
            String id = teaSeedNameList.get(i);

            String pinyin = CommonUtils.converterToPinYin(dataItem);
            BrandName brandName = new BrandName(id, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
        //liu liqi
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String seedName = agent.getCategory(indexs.x, indexs.y).getName();   //茶类名
            String seedCode = agent.getCategory(indexs.x, indexs.y).getCode();   //茶类码
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(seedName)) {
                    listAdapter.setSelectedIndex(i);
                    clickItem = allCharacterList.get(i);
                    CommonUtils.cachingCategoryCode(getApplicationContext(), seedCode, seedName);
                    TEA_SEED_POSITION = i;  //改变记录选中下标
                    CategoryTeaBrandFilterActivity.TEA_SEED_CHANGE = true;
                    break;
                }
            }
            listAdapter.notifyDataSetChanged();
            disapearThread = new DisapearThread();
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
            return;
        }

        // 获取上次点击的行数
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.CATEGORY);
        List<Tuple<String, String>> tuples = new ArrayList<>();
        for (int i = 0; i < teaSeedItem.size(); i++) {
            tuples.add(teaSeedItem.get(i).getCategoryTuple());
        }
        Tuple<Integer, Integer> index = CommonUtils.getAcacheIndex(tuple,
                tuples);
        if (index != null) {
            listAdapter.setSelectedIndex(index.getSecondValue() + 1);

        } else {
            listAdapter.setSelectedIndex(0);
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新茶种UI
     */
    private void updateTeaSortView(ArrayList<TeaCategoryItem> list) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        //liu liqi
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String seedCode = agent.getCategory(indexs.x, indexs.y).getCode();   //茶类码
            String seedName = agent.getCategory(indexs.x, indexs.y).getName();   //茶类名
            for (int i = 0; i < list.size(); i++) {
                String first = list.get(i).getCategoryTuple().getFirstValue();    //二级分类码
                if (seedCode.equals(first)) {
                    TEA_SEED_POSITION = i + 1;
                    for (int j = 0; j < list.get(i).getPropertyTupleList().size(); j++) {
                        model.add(list.get(i).getPropertyTupleList().get(j).getSecondValue());
                        teaSortList.add(list.get(i).getPropertyTupleList().get(j).getFirstValue());
                    }
                }
            }
            CommonUtils.cachingCategoryCode(getApplicationContext(), seedCode, seedName);
            CategoryTeaBrandFilterActivity.TEA_SEED_CHANGE = true;
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
        } else {
            for (int i = 0; i < list.get(TEA_SEED_POSITION - 1).getPropertyTupleList().size(); i++) {
                model.add(list.get(TEA_SEED_POSITION - 1).getPropertyTupleList().get(i).getSecondValue());
                teaSortList.add(list.get(TEA_SEED_POSITION - 1).getPropertyTupleList().get(i).getFirstValue());
            }
        }
        teaSortNameList.clear();
        teaSortNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();

        // 获取姓名的拼音缩写
        for (int i = 0; i < teaSortNameList.size(); i++) {
            String dataItem = teaSortNameList.get(i);
            String id = teaSortNameList.get(i);

            String pinyin = CommonUtils.converterToPinYin(dataItem);
            BrandName brandName = new BrandName(id, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 属性列表打勾
     */
    private void checkTextViewIndex(List<List<Tuple<String, String>>> list) {
        ACache aCache = ACache.get(getApplicationContext());
        CachingArrayList tupleProperty = (CachingArrayList) aCache.getAsObject(CommonConst.ACacheComstants.PROPERTY);
        if (tupleProperty == null) {
            listAdapter.setSelectedIndex(0);
            listAdapter.notifyDataSetChanged();
            return;
        }
        final String code1 = tupleProperty.size() > 0 ? tupleProperty.get(0).getSecondValue() : null;
        final String code2 = tupleProperty.size() > 1 ? tupleProperty.get(1).getSecondValue() : null;
        List<String> codes = new ArrayList<String>() {
            {
                if (code1 != null) {
                    add(code1);
                }
                if (code2 != null) {
                    add(code2);
                }
            }
        };
        for (int i = 0; i < codes.size(); i++) {
            String code = codes.get(i);
            listAdapter.setSelectedIndex(0);
            for (int j = 0; j < list.size(); j++) {
                List<Tuple<String, String>> itemList = list.get(j);
                for (int k = 0; k < itemList.size(); k++) {
                    Tuple<String, String> tuple = itemList.get(k);
                    if (code.equals(tuple.getFirstValue())) {
                        listAdapter.setSelectedIndex(k + 1);
                        i = codes.size();
                    }
                }
            }
            listAdapter.notifyDataSetChanged();
        }
    }

    /**
     * 设置适配器设置标题
     *
     * @param titleName
     *         标题名
     * @param sort
     *         是否排序
     * @param visible
     *         是否显示列表右侧英文导航
     */
    private void setAdapterTitle(String titleName, boolean sort, int visible) {
        title.setText(titleName);
        rclstNavigation.setVisibility(visible);  //右侧英文导航栏可见
        // 初始化listview的适配器
        listAdapter = new BrandNameListAdapter(this, allCharacterList, sort);
        // 设置品牌名称ListView的适配器
        lstBrandName.setAdapter(listAdapter);
    }

    /**
     * 设置监听
     */
    private void setListener() {
        llytCancel.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // 本画面结束
                finish();
            }
        });
        llytOk.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // 什么也没点击获取缓存数据
                noClick();
                // 回调方法，传回意图对象
                setResult(RESULT_OK, brandData);
                // 本活动结束
                CategoryTeaBrandFilterActivity.this.finish();
            }
        });
    }

    /**
     * 通过任务的数据来更新香型UI
     */
    private void updateOrdorTypeView(SpiritCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getOdorTupleList().size(); i++) {
            model.add(item.getOdorTupleList().get(i).getSecondValue()); //香型
            ordorList.add(item.getOdorTupleList().get(i).getFirstValue());  //香型码
        }

        ordorNameList.clear();
        ordorNameList.addAll(model);

        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : ordorNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新葡萄酒产地UI
     */
    private void updateRedWineView(WineCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getProductionTupleList().size(); i++) {
            model.add(item.getProductionTupleList().get(i).getSecondValue());
            redWinePlaceList.add(item.getProductionTupleList().get(i).getFirstValue());
        }
        redWinePlaceNameList.clear();
        redWinePlaceNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : redWinePlaceNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新洋酒颜色UI
     */
    private void updateForeignWineColorView(ForeignWineCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getClassifyTupleList().size(); i++) {
            model.add(item.getClassifyTupleList().get(i).getSecondValue());
            foreignClassifyList.add(item.getClassifyTupleList().get(i).getFirstValue());
        }
        foreignClassifyNameList.clear();
        foreignClassifyNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : foreignClassifyNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新洋酒国家UI
     */
    private void updateForeignWineCountryView(ForeignWineCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getCountryTupleList().size(); i++) {
            model.add(item.getCountryTupleList().get(i).getSecondValue());
            foreignCountryList.add(item.getCountryTupleList().get(i).getFirstValue());
        }
        foreignCountryNameList.clear();
        foreignCountryNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : foreignCountryNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新啤酒国家UI
     */
    private void updateBeerCountryView(BeerCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getCountryTupleList().size(); i++) {
            model.add(item.getCountryTupleList().get(i).getSecondValue());
            beerCountryList.add(item.getCountryTupleList().get(i).getFirstValue());
        }
        beerCountryNameList.clear();
        beerCountryNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : beerCountryNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新啤酒分类UI
     */
    private void updateBeerClassifyView(BeerCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getClassifyTupleList().size(); i++) {
            model.add(item.getClassifyTupleList().get(i).getSecondValue());
            beerClassifyList.add(item.getClassifyTupleList().get(i).getFirstValue());
        }
        beerClassifyNameList.clear();
        beerClassifyNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : beerClassifyNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        listAdapter.notifyDataSetChanged();
    }

    /**
     * 通过任务的数据来更新茶品牌UI
     */
    private void updateBrandListView(ArrayList<TeaCategoryItem> list) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        //liu liqi
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String seedCode = agent.getCategory(indexs.x, indexs.y).getCode();   //茶类码
            String seedName = agent.getCategory(indexs.x, indexs.y).getName();   //茶类名
            for (int i = 0; i < list.size(); i++) {
                String first = list.get(i).getCategoryTuple().getFirstValue();    //二级分类码
                if (seedCode.equals(first)) {
                    TEA_SEED_POSITION = i + 1;
                    for (int j = 0; j < list.get(i).getPropertyTupleList().size(); j++) {
                        model.add(list.get(i).getPropertyTupleList().get(j).getSecondValue());
                        teaSortList.add(list.get(i).getPropertyTupleList().get(j).getFirstValue());
                    }
                }
            }
            CommonUtils.cachingCategoryCode(getApplicationContext(), seedCode, seedName);
            CategoryTeaBrandFilterActivity.TEA_SEED_CHANGE = true;
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
        } else {
            for (int i = 0; i < list.get(TEA_SEED_POSITION - 1).getBrandTupleList().size(); i++) {
                model.add(list.get(TEA_SEED_POSITION - 1).getBrandTupleList().get(i).getSecondValue());
                brandCodeList.add(list.get(TEA_SEED_POSITION - 1).getBrandTupleList().get(i).getFirstValue());
            }
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();

        // 获取姓名的拼音缩写
        for (int i = 0; i < brandNameList.size(); i++) {
            String dataItem = brandNameList.get(i);
            String name = brandNameList.get(i);

            String pinyin = CommonUtils.converterToPinYin(dataItem);
            BrandName brandName = new BrandName(name, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (!TEA_SEED_CHANGE) {
            if (tuple != null) {
                for (int i = 0; i < allCharacterList.size(); i++) {
                    if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                        listAdapter.setSelectedIndex(i);
                    }
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新白酒品牌UI
     */
    private void updateBrandWineListView(SpiritCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }

        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();

        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        //liu liqi
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String brandName = agent.getCategory(indexs.x, indexs.y).getName();   //白酒二级分类名
            String brandCode = agent.getCategory(indexs.x, indexs.y).getCode();   //白酒二级分类码
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(brandName)) {
                    listAdapter.setSelectedIndex(i);
                    clickItem = allCharacterList.get(i);
                    CommonUtils.cachingBrandId(getApplicationContext(), brandCode, brandName);   //品牌放入缓存
                    break;
                }
            }
            listAdapter.notifyDataSetChanged();
            disapearThread = new DisapearThread();
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
            return;
        }
        //上次点击的位置
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新葡萄酒酒品牌UI
     */
    private void updateBrandRedWineListView(WineCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        //首页点击二级分类直接进入 liuliqi
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String brandName = agent.getCategory(indexs.x, indexs.y).getName();   //葡萄酒二级分类名
            String brandCode = agent.getCategory(indexs.x, indexs.y).getCode();   //葡萄酒二级分类码
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(brandName)) {
                    listAdapter.setSelectedIndex(i);
                    clickItem = allCharacterList.get(i);
                    CommonUtils.cachingBrandId(getApplicationContext(), brandCode, brandName);   //品牌放入缓存
                    break;
                }
            }
            listAdapter.notifyDataSetChanged();
            disapearThread = new DisapearThread();
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
            return;
        }
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 其它 类 无品牌了
     * 通过任务的数据来更新其它UI
     */
    private void updateBrandOtherWineListView(OthersCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());

        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新洋酒酒品牌UI
     */
    private void updateBrandForeignWineListView(ForeignWineCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        //点击首页二级分类直接进入时候
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String brandName = agent.getCategory(indexs.x, indexs.y).getName();   //洋酒二级分类名
            String brandCode = agent.getCategory(indexs.x, indexs.y).getCode();   //洋酒二级分类码
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(brandName)) {
                    listAdapter.setSelectedIndex(i);
                    clickItem = allCharacterList.get(i);
                    CommonUtils.cachingBrandId(getApplicationContext(), brandCode, brandName);   //品牌放入缓存
                    break;
                }
            }
            listAdapter.notifyDataSetChanged();
            disapearThread = new DisapearThread();
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
            return;
        }
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新啤酒酒品牌UI
     */
    private void updateBeerListView(BeerCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        //点击首页二级分类直接进入时
        Int2 indexs = SerializeCache.getInstance().getCategoryIndexs();
        if (indexs.y != -1) {
            if (agent.getCategory(indexs.x, indexs.y) == null) {
                return;
            }
            String brandName = agent.getCategory(indexs.x, indexs.y).getName();   //啤酒二级分类名
            String brandCode = agent.getCategory(indexs.x, indexs.y).getCode();   //啤酒二级分类码
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(brandName)) {
                    listAdapter.setSelectedIndex(i);
                    clickItem = allCharacterList.get(i);
                    CommonUtils.cachingBrandId(getApplicationContext(), brandCode, brandName);   //品牌放入缓存
                    break;
                }
            }
            listAdapter.notifyDataSetChanged();
            disapearThread = new DisapearThread();
            SerializeCache.getInstance().saveCategorySecondIndexs(-1);   //将二级品类恢复为点击了全部商品
            return;
        }
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 初始化首字母悬浮提示框
     */
    private void initFirstLetterFlateTips() {
        txtOverlay.setVisibility(View.INVISIBLE);
        LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, LayoutParams.TYPE_APPLICATION, LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE, PixelFormat.TRANSLUCENT);
        // 屏幕管理器
        WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
        windowManager.addView(txtOverlay, lp);
    }

    /**
     * 通过任务的数据来更新饮料品牌UI
     */
    private void updateBrandDrinksListView(DrinksCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新粮油品牌UI
     */
    private void updateBrandGrainListView(GrainCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());

        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新副食品牌UI
     */
    private void updateBrandNonStapleListView(NonStapleCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新日化用品品牌UI
     */
    private void updateBrandDailyUsedListView(DailyUsedCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));   //"全部"
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        //获取缓存的上次所选品牌并设置为默认所选
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新五金品牌UI
     */
    private void updateBrandHardwareListView(HardwareCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));   //"全部"
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());

        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 通过任务的数据来更新家电品牌UI
     */
    private void updateBrandElectricListView(ElectricCategoryItem item) {
        // 有结果
        List<String> model = new ArrayList<>();
        model.add((String) getResources().getText(R.string.category_all_label));   //"全部"
        for (int i = 0; i < item.getBrandTupleList().size(); i++) {
            model.add(item.getBrandTupleList().get(i).getSecondValue());
            brandCodeList.add(item.getBrandTupleList().get(i).getFirstValue());
        }
        brandNameList.clear();
        brandNameList.addAll(model);
        singleCharacterList.clear();
        allCharacterList.clear();
        // 获取姓名的拼音缩写
        for (String str : brandNameList) {
            String pinyin = CommonUtils.converterToPinYin(str);
            BrandName brandName = new BrandName(str, pinyin);
            allCharacterList.add(brandName);
            String firstLetter = CommonUtils.getFirstLetter(pinyin);
            if (!singleCharacterList.contains(firstLetter)) {
                singleCharacterList.add(firstLetter);
            }
        }
        // 转换成大写字母
        for (int i = 0; i < singleCharacterList.size(); i++) {
            String string = singleCharacterList.get(i);
            singleCharacterList.set(i, string.toUpperCase());
        }
        // 开头加上#字符
        singleCharacterList.add(0, "#");
        rclstNavigation.setOnTouchingLetterChangedListener(new LetterListViewListener());
        handler = new Handler();
        // 初始化首字母悬浮提示框
        initFirstLetterFlateTips();
        // 初始化ListAdapter
        // 进行排序操作
        sortData(allCharacterList);
        Tuple<String, String> tuple = (Tuple<String, String>) ACache.get(this).getAsObject(CommonConst.ACacheComstants.BRAND);
        listAdapter.setSelectedIndex(0);
        if (tuple != null) {
            for (int i = 0; i < allCharacterList.size(); i++) {
                if (allCharacterList.get(i).getName().equals(tuple.getSecondValue())) {
                    listAdapter.setSelectedIndex(i);
                    break;
                }
            }
        }
        listAdapter.notifyDataSetChanged();
        disapearThread = new DisapearThread();
    }

    /**
     * 对数据进行排序。
     *
     * @param allCharacterList
     *         排序数据
     */
    private void sortData(List<BrandName> allCharacterList) {
        for (int i = 0; i < allCharacterList.size() - 1; i++) {
            for (int j = 0; j < allCharacterList.size() - 1 - i; j++) {
                if (CommonUtils.getFirstLetter(allCharacterList.get(j).getPinYin().toUpperCase()).charAt(0) > CommonUtils.getFirstLetter(allCharacterList.get(j + 1).getPinYin().toUpperCase()).charAt(0)) {
                    BrandName brand = allCharacterList.get(j);
                    allCharacterList.set(j, allCharacterList.get(j + 1));
                    allCharacterList.set(j + 1, brand);
                }
            }
        }
        for (int j = 0; j < allCharacterList.size(); j++) {
            if (allCharacterList.get(j).getPinYin().equals("qbpp")) {
                allCharacterList.add(0, allCharacterList.get(j));
                allCharacterList.remove(j + 1);
                break;
            }
        }
        for (int j = 0; j < allCharacterList.size(); j++) {
            if (allCharacterList.get(j).getPinYin().equals("qb")) {
                allCharacterList.add(0, allCharacterList.get(j));
                allCharacterList.remove(j + 1);
                break;
            }
        }
    }

    /**
     * 品牌。
     *
     * @author muwei
     * @version 1.00 2013/11/18 新建
     */
    public static class BrandName {
        /**
         * 品牌名
         */
        private String name;
        /**
         * 品牌拼音
         */
        private String pinYin;

        BrandName(String name, String pinYin) {
            super();
            this.name = name;
            this.pinYin = pinYin;
        }

        public String getPinYin() {
            return pinYin;
        }

        public void setPinYin(String pinYin) {
            this.pinYin = pinYin;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

    }

    /**
     * 字母导航监听。
     */
    private class LetterListViewListener implements OnTouchingLetterChangedListener {

        @Override
        public void onTouchingLetterChanged(final String s) {
            // 泡泡显示字母
            txtOverlay.setText(s);
            if (txtOverlay.getVisibility() == View.VISIBLE) {
                handler.removeCallbacks(disapearThread);
            } else {
                txtOverlay.setVisibility(View.VISIBLE);
            }
            // 提示延迟0.5s再消失
            handler.postDelayed(disapearThread, 1000);
            int num = 0;
            for (int i = 0; i < allCharacterList.size(); i++) {
                if ("a".equals(s)) {
                    num = 0;
                } else if (CommonUtils.character2ASCII(CommonUtils.getFirstLetter(allCharacterList.get(i).getPinYin().toLowerCase())) < (CommonUtils.character2ASCII(s) + 32)) {
                    num += 1;
                }
            }
            num += 1;
            lstBrandName.setSelectionFromTop(num, 0);
        }
    }

    /**
     * 删除浮动文本的线程。
     */
    private class DisapearThread implements Runnable {

        @Override
        public void run() {
            // 避免在1s内，用户再次拖动时提示框又执行隐藏命令。
            txtOverlay.setVisibility(View.INVISIBLE);
        }
    }
}